/*
 *--------------------------------------------------------------------------
 *   File Name:	entry.S
 * 
 * Description:	none
 * 
 * 
 *      Author:	Zhao Yanbai [zhaoyanbai@126.com]
 * 
 *     Version:	1.0
 * Create Date: Thu Jul 09 19:56:40 2009
 * Last Update: Thu Jul 09 19:56:40 2009
 * 
 *--------------------------------------------------------------------------
 */
#define	ASM
#include<system.h>
#include<linkage.h>

// Stack's esp should be change here

#define	EC_ENTRY(name)			\
	.extern	do##name;		\
	ENTRY(name)

#define	EC_CALLDO(name)			\
	SAVE_REGS			\
	call	do##name;		\
	RESTORE_REGS;			\
	addl	$4,%esp;		\
	iret;

#define	NOERRCODE(name)			\
	EC_ENTRY(name)			\
	pushl	$0;			\
	EC_CALLDO(name)
#define	ERRORCODE(name)			\
	EC_ENTRY(name)			\
	EC_CALLDO(name)
#if 0
#define	NOERRCODE(name)			\
	.extern	do##name;		\
	.global	name;			\
	.align	4,0x90;			\
	name:				\
	pushl	$0;			\
	SAVE_ALL			\
	call	do##name;		\
	RESTORE_ALL;			\
	addl	$4,%esp;		\
	iret;

#define	ERRORCODE(name)			\
	.extern	do##name;		\
	.global	name;			\
	.align	4,0x90;			\
	name:				\
	SAVE_ALL			\
	call	do##name;		\
	RESTORE_ALL;			\
	addl	$4,%esp;		\
	iret;
#endif

NOERRCODE	(DivideError)
NOERRCODE	(Debug)
NOERRCODE	(NMI)
NOERRCODE	(BreakPoint)
NOERRCODE	(OverFlow)
NOERRCODE	(BoundsCheck)
NOERRCODE	(InvalidOpcode)
NOERRCODE	(DeviceNotAvailable)
NOERRCODE	(DoubleFault)
NOERRCODE	(CoprocSegOverRun)
ERRORCODE	(InvalidTss)
ERRORCODE	(SegNotPresent)
ERRORCODE	(StackFault)
ERRORCODE	(GeneralProtection)
ERRORCODE	(PageFault)
NOERRCODE	(CoprocError)

